import { createRouter, createWebHistory } from 'vue-router'
import LayoutView from '../views/LayoutView.vue'
import DashboardView from '../views/DashboardView.vue'
import RecipesView from '../views/RecipesView.vue'
import BrewingView from '../views/BrewingView.vue'
import InventoryView from '../views/InventoryView.vue'
import SettingsView from '../views/SettingsView.vue'
import ToolsView from '../views/ToolsView.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      component: LayoutView,
      children: [
        {
          path: '',
          redirect: { name: 'dashboard' }
        },
        {
          path: 'dashboard',
          name: 'dashboard',
          component: DashboardView
        },
        {
          path: 'recipes',
          name: 'recipes',
          component: RecipesView
        },
        {
          path: 'recipes/:id',
          name: 'recipe-detail',
          component: () => import('../views/RecipeDetailView.vue'),
          props: true
        },
        {
          path: 'brewing',
          name: 'brewing',
          component: BrewingView
        },
        {
          path: 'brewing/new',
          name: 'brewing-new',
          component: () => import('../views/BrewingNewView.vue'),
          props: true
        },
        {
          path: 'inventory',
          name: 'inventory',
          component: InventoryView
        },
        {
          path: 'settings',
          name: 'settings',
          component: SettingsView
        },
        {
          path: 'tools',
          name: 'tools',
          component: ToolsView
        },
        // 工具子路由
        {
          path: 'tools/plato-calculator',
          name: 'plato-calculator',
          component: () => import('../views/tools/PlatoCalculator.vue')
        },
        {
          path: 'tools/abv-calculator',
          name: 'abv-calculator',
          component: () => import('../views/tools/ABVCalculator.vue')
        },
        {
          path: 'tools/color-converter',
          name: 'color-converter',
          component: () => import('../views/tools/ColorConverter.vue')
        },
        {
          path: 'tools/hydrometer-correction',
          name: 'hydrometer-correction',
          component: () => import('../views/tools/HydrometerCorrection.vue')
        },
        {
          path: 'tools/yeast-calculator',
          name: 'yeast-calculator',
          component: () => import('../views/tools/YeastCalculator.vue')
        },
        {
          path: 'tools/calorie-calculator',
          name: 'calorie-calculator',
          component: () => import('../views/tools/CalorieCalculator.vue')
        },
        {
          path: 'tools/fruit-dilution',
          name: 'fruit-dilution',
          component: () => import('../views/tools/DilutionCalculator.vue')
        },
        {
          path: 'tools/speise-calculator',
          name: 'speise-calculator',
          component: () => import('../views/tools/SpeiseCalculator.vue')
        },
        {
          path: 'tools/beer-name-generator',
          name: 'beer-name-generator',
          component: () => import('../views/tools/BeerNameGenerator.vue')
        },
        {
          path: 'tools/beer-menu',
          name: 'beer-menu',
          component: () => import('../views/tools/BeerMenu.vue')
        },
        // 重定向旧的啤酒菜单路由到新的路由
        {
          path: 'tools/cyberpunk-beer-menu',
          redirect: { name: 'beer-menu' }
        }
      ]
    }
  ]
})

export default router 